<template>
  <div class="recommended-up">
    <h3>推荐UP主</h3>
    <div class="up-list">
      <div 
        v-for="up in upList" 
        :key="up.id" 
        class="up-item" 
        @click="handleUpClick(up.id)"
      >
        <div class="up-card">
          <div class="up-header">
            <img v-img-error :src="up.avatar" alt="UP主头像" class="up-avatar">
            <div class="up-basic-info">
              <div class="up-name">
                {{ up.name }}
                <i v-if="up.isOfficial" class="fas fa-check-circle official-badge" title="官方认证"></i>
              </div>
              <div class="up-meta">
                <span class="up-fans">{{ up.fans }}粉丝</span>
                <span class="up-category">{{ up.category }}</span>
                <span class="up-level">Lv.{{ up.level }}</span>
              </div>
            </div>
            <button 
              class="follow-btn" 
              :class="{ 'following': up.isFollowing }"
              @click.stop="handleFollowUp(up.id)"
            >
              {{ up.isFollowing ? '已关注' : '+ 关注' }}
            </button>
          </div>
          <div class="up-content">
            <p class="up-description">{{ up.description }}</p>
            <div class="up-featured">
              <span class="featured-label">代表作品：</span>
              <span class="featured-video">{{ up.featuredVideo }}</span>
            </div>
          </div>
          <div class="up-stats">
            <span class="total-views">{{ up.totalViews }}播放</span>
            <span class="recent-works">{{ up.recentWorks }}部近期作品</span>
            <span v-if="up.verifiedStatus" class="verified-status">{{ up.verifiedStatus }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'RecommendedUp',
  props: {
    upList: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    handleUpClick(upId) {
      this.$emit('up-click', upId)
    },
    handleFollowUp(upId) {
      this.$emit('follow-up', upId)
    },
  },
}
</script>

<style scoped>
.recommended-up {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.recommended-up h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.up-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.up-item {
  cursor: pointer;
}

.up-card {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
}

.up-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.up-card:hover .up-avatar {
  transform: scale(1.1);
}

.up-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.up-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
  transition: transform 0.3s ease;
  border: 2px solid #f0f0f0;
}

.up-basic-info {
  flex: 1;
  min-width: 0;
}

.up-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.official-badge {
  color: #1890ff;
  font-size: 12px;
}

.up-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #999;
}

.follow-btn {
  padding: 6px 12px;
  border: 1px solid #1890ff;
  border-radius: 4px;
  background: white;
  color: #1890ff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.follow-btn:hover {
  background: #e6f7ff;
}

.follow-btn.following {
  background: #f0f0f0;
  border-color: #f0f0f0;
  color: #999;
}

.up-content {
  margin-bottom: 10px;
}

.up-description {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.up-featured {
  font-size: 12px;
  color: #999;
}

.featured-label {
  font-weight: 500;
}

.featured-video {
  color: #1890ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 4px;
}

.up-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: #999;
}

.total-views {
  color: #666;
}

.verified-status {
  color: #1890ff;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .recommended-up {
    padding: 12px;
  }
  
  .up-card {
    padding: 10px;
  }
  
  .up-avatar {
    width: 40px;
    height: 40px;
  }
  
  .up-meta {
    flex-wrap: wrap;
  }
  
  .up-stats {
    gap: 8px;
    font-size: 11px;
  }
}
</style>